import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// UI组件库按需加载
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import eslintPlugin from 'vite-plugin-eslint'

// https://vitejs.dev/config/
export default defineConfig({
	base: '/qf-admin-pro',
	plugins: [
		vue(),
		// * EsLint 报错信息显示在浏览器界面上
		eslintPlugin(), // 变量定义了没使用  页面也要报错
		// UI组件库按需加载
		AutoImport({
			resolvers: [ElementPlusResolver()]
		}),
		Components({
			resolvers: [ElementPlusResolver()]
		})
		// ...
	],
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url)),
			'~mock': fileURLToPath(new URL('./mock', import.meta.url))
		}
	},
	css: {
		preprocessorOptions: {
			// define global scss variable
			scss: {
				additionalData: `@import '@/styles/variables.scss';`
			}
		}
	},
	server: {}
})
